package cn.tedu.micro.demo.device.service.impl;

import cn.tedu.micro.demo.common.vo.GunInfoVO;
import cn.tedu.micro.demo.device.dao.mapper.GunInfoMapper;
import cn.tedu.micro.demo.device.dao.repository.DeviceRepository;
import cn.tedu.micro.demo.device.po.GunInfoPO;
import cn.tedu.micro.demo.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private DeviceRepository deviceRepository;
//    @Autowired
//    private GunInfoMapper gunInfoMapper;

    @Override
    public GunInfoVO checkGunStatus(Integer id) {
        log.info("开始查询枪的状态");
        GunInfoVO vo =null;
        //1.调用持久层 读取枪完整po
        //select * from gun_info where id=?
        GunInfoPO po= deviceRepository.getGunById(id);
        log.info("查询到的枪的信息为:{}",po);
        if(po!=null){
            log.info("查询到枪的信息");
            vo = new GunInfoVO();
            BeanUtils.copyProperties(po,vo);
          log.info("转换后的结果为:{}",vo);
        }else{
            log.info("没有查询到枪的信息");
        }
        log.info("结束查询枪的状态", vo);
        return vo;

    }
}
